@extends("home.base")
@section("content")


<title>我的收货地址薄</title>
<link rel="stylesheet" href="{{asset('personal/myaddress/my_account_address.css')}}">
<link rel="stylesheet" href="{{asset('personal/myaddress/reco_wrap.css')}}">
<link href="{{asset('personal/myaddress/mydd_head.css')}}" rel="stylesheet" type="text/css">
<link href="{{asset('personal/myaddress/mydd_public.css')}}" rel="stylesheet" type="text/css">
<link href="{{asset('personal/myaddress/mydd_title.css')}}" rel="stylesheet" type="text/css">
<link href="{{asset('personal/myaddress/mydd_leftnavi.css')}}" rel="stylesheet" type="text/css">
<link href="{{asset('personal/myaddress/mydd_foot.css')}}" rel="stylesheet" type="text/css">
<link href="{{asset('personal/myaddress/header_960_150803.css')}}" rel="stylesheet" type="text/css">


<div class="mydnew_break">
	您现在的位置：<a href="#">当当</a> &gt; <span><a href="#">我的当当</a></span> &gt; <span>收货地址簿</span>
</div>
<link href="{{asset('personal/myaddress/mydnew2.css')}}" rel="stylesheet" type="text/css">
<link href="{{asset('personal/myaddress/dangdang.css')}}" rel="stylesheet" type="text/css">
<link href="{{asset('personal/myaddress/mydnew.css')}}" rel="stylesheet" type="text/css">
<div class="main_frame">
	<div class="mydang_left">
		<div class="mydang_left_inner">
			<h3 class="mydang_left_title border_top0">我的常用链接<a id="DocPersonal_set" name="setting" href="#" style="font-size: 12px; color:#1A66B3; font-family: 宋体; font-weight:normal; padding-left: 40px;">设置</a></h3>
			<ul style="padding:0px;" class="my_href" id="myfavoriteLink">
				<input type="hidden" id="rememberCustomerID" value="0">
			</ul>
			<h3 class="mydang_left_title">个人中心<a class="slide_up" id="class600" href="#"></a></h3>
			<ul class="my_content" style="display:block;" id="display600">
				<li><a class="" target="_parent" href="{{url('home/myorder')}}" name="myallorders">我的订单</a>
				</li>
				<li><a class="" target="_parent" href="{{url('home/myinfo')}}" name="profileleft">个人信息</a>
				</li>
				<li><a href="{{url('home/address/index')}}" class="on">收货地址</a>
				</li>
			</ul>
			<h3 class="mydang_left_title">我的收藏<a class="slide_up" id="class610" href="#"></a></h3>
			<ul class="my_content" style="display:block;" id="display610">
				<li><a class="" target="_parent" href="#" name="wishlist">商品收藏</a>
				</li>
				
			</ul>
		</div>
	</div>
	<link type="text/css" rel="stylesheet" href="{{asset('personal/myaddress/mydang.css')}}">
	<style type="text/css">
     /*设置弹出效果*/
.new_window{width:337px; border:solid 2px #447aa9; background-color:#f7fff8}
.wind_top{height:20px; padding:2px 2px 0 8px; background-color:#458bc9}
.wind_top .title_left{padding-top:2px; color:#fff; float:left}
.w_close{ float:right}
	</style>
	
	
	<div id="tag_box1" style="display:none;position:absolute; z-index:20000;">
	</div>
	
	<div id="account_right" class="account_right">
		<div id="list">
			<div class="problem">
			</div>
			<h2>收货地址簿</h2>
			<div class="clear">
			</div>
			<div id="orderList">
				<div class="my_address_info">
					@foreach($list as $v)
					<div id="div_addrs_{{$v->id}}" class="other_address" style="display: block;">
						<ul>
							<li>
							<span class="address_num"></span>
							<span class="address_text">{{$v->pName}},&nbsp;中国,&nbsp;{{$v->province}},&nbsp;{{$v->city}},&nbsp;{{$v->area}}@if(!empty($v->xiang)),&nbsp;{{$v->xiang}}@endif,&nbsp;{{$v->street}},&nbsp;{{$v->post}}102200,&nbsp;{{$v->phone}}</span>
							</li>
							<li class="my_address_btn">
							<a href="{{url('home/address/')}}/{{$v->id}}/edit"><input type="button" onclick="" value="修 改" name="button_update" class="button_delete"></a>
							<input type="button" onclick="del({{$v->id}},this);" value="删 除" name="button_delete" class="button_delete">
							<span><a href="#" onclick="set_default({{$v->id}})">设为默认地址</a></span>
							</li>
						</ul>
						<div class="clear">
						</div>
					</div>
					@endforeach 
					<div class="my_address_dashed">
					</div>
				</div>
			</div>
			
			<div class="fanye" id="div_paging">
				<a class="fanye_page fanye_none" href="#"><span>下一页</span></a><a class="nonce"><span>1</span></a><a class="fanye_page fanye_none" href="#"><span>上一页</span></a>
			</div>
			<div class="my_address_info my_address_add" id="myaddress_container">
				<h5>新增/修改收货地址</h5>
				<form method="post" name="myaddress" action="" id="myaddress">
				<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
					<div class="my_address_add_info">
						<p>
							<label><strong>*</strong>收货人：</label><input type="text" name="shouname" id="ship_man" maxlength="40" onfocus="check_focus(&#39;spn_ship_man&#39;);" onblur="check_ship_man();">
							<label style="display:none">身份证：</label><input style="display:none" name="id_card" type="text" id="id_card" maxlength="18" onfocus="check_focus(&#39;spn_ship_man&#39;);" onblur="check_id_card();"><span id="spn_ship_man" class="hint new_tip" style="display: none;">请填写收货人姓名</span>
						</p>
						<p id="area">
							<label><strong>*</strong>地区：</label>
							<div id="myaddr" style="display:inline">
							
							</div>
							<span id="spn_country_province_city" class="hint new_tip" style="display: none">请选择完整的收货地址信息</span>
						</p>
						<p>
							<label><strong>*</strong>街道地址：</label><input type="text" id="addr_detail" name="detailaddr" onfocus="check_country_province_city(); check_focus(&#39;spn_addr_detail&#39;);" onblur="check_addr_detail();" maxlength="200" size="50">
							<span id="spn_addr_detail" class="hint new_tip" style="display: none;">请填写街道地址</span>
						</p>
						<p>
							<label><strong>*</strong>邮政编码：</label><input type="text" id="ship_zip" name="post" onfocus="check_focus(&#39;spn_ship_zip&#39;);" onblur="check_ship_zip();">
							<span id="spn_ship_zip" class="hint new_tip" style="display: none">请填写您的邮编 正确的邮编有助于加快送货速度</span>
						</p>
						<p>
							<label><strong>*</strong>电话：</label><input type="text" id="ship_mb" name="phone" onfocus="check_focus(&#39;spn_ship_mb&#39;, &#39;ship_mb&#39;);" onblur="check_ship_mb();">
							<span id="spn_ship_mb" class="hint new_tip" style="display: none">请填写手机号码</span>
							<input type="hidden" id="ship_mb_hidden" name="ship_mb_hidden">
							<input type="hidden" id="ship_tel_hidden" name="ship_tel_hidden">
							<input type="hidden" id="ship_man_hidden" name="ship_man_hidden">
						</p>
						<p class="address_add_checkbox">
							<input type="checkbox" value="" name="default_flg" id="default_flg"><span>设为默认地址</span>
						</p>
						<p class="address_add_btn">
							<button onclick="Add();">保存</button>
						</p>
						<input id="cust_address_id" name="cust_address_id" type="text" value="0" style="display: none">
						<input id="status" name="status" type="text" value="2" style="display: none">
					</div>
				</form>
			</div>
			<script type="text/javascript">
				//添加新的收获地址
				 $(function(){
                //获取input节点并添加点击事件
					$(":checkbox").click(function(){
                    //获取判断是否选中
						if($(this).attr("checked")){
                       
							$(this).val("1");
						}else{
							$(this).val("0");
						}
					});
				});

				function Add(){
					
					$("#myaddress").attr("action","{{url('home/myaddress')}}").submit();
				}
			</script>
			<script type="text/javascript">
				//添加新的收获地址判定
				//判断收货人
				$("#ship_man").blur(function(){
					var name = $("#ship_man").val();
					if(name == ""){
						$("#spn_ship_man").attr("style","display:block");
					}else{
						$("#spn_ship_man").attr("style","display:none");
					}
				});
				//判断省份地址
				$("#selectaddr").blur(function(){
					
					if ($('#selectaddr').is(':visible') && $('#selectaddr').val() == 0)
						{
							check_wrong('spn_country_province_city');
							return false;
						}else{
							
						}alert("dfs");
				});
				
				//判断街道地址
				$("#addr_detail").blur(function(){
					if($("#addr_detail").val() == ""){
						$("#spn_addr_detail").attr("style","display:block");
					}else{
						$("#spn_addr_detail").attr("style","display:none");
					}
				});
				//判断邮政编码
				$("#ship_zip").blur(function(){
					if($("#ship_zip").val() == ""){
						$("#spn_ship_zip").attr("style","display:block");
					}else{
						$("#spn_ship_zip").attr("style","display:none");
					}
				});
				//判断手机号
				$("#ship_mb").blur(function(){
					if($("#ship_mb").val() == ""){
						$("#spn_ship_mb").attr("style","display:block");
					}else{
						$("#spn_ship_mb").attr("style","display:none");
					}
				});

			</script>
			<script type="text/javascript">
			  //城市级联操作
			  function loadDistrict(upid){
				 $.ajax({
					url:"{{URL('home/district')}}/"+upid,
					type:"get",
					dataType:"json",
					async:true,
					success:function(data){
						if(data.length<1){
							return;
						}
						
						 var select = '<select name="address" id="selectaddr" class="form-control" style="display: block;">';
						select += "<option>-请选择-</option>";
						for(var i=0;i<data.length;i++){
							select += "<option value='"+data[i].id+"'>";
							select += data[i].name;
							select += "</option>";
						}
						select +="</select>";
						//添加
						//$("#myaddrform").append(select);
						$(select).change(function(){
									$(this).nextAll("select").remove();
									var id = $(this).find("option:selected").val();
									loadDistrict(id);
							  }).appendTo("#myaddr");
					},
					error:function(){
						alert("I am so sorry~~~");
					}
				 });
			  }
			  
			  loadDistrict(0);
			</script>
			<!--确认弹出层-->
			<div style="z-index: 101; position: absolute; display: none; left: 625px; top: 618px;" class="windo_add_shadow" id="div_confirm_delete">
				<div class="windo_top_shadow">
					<div class="windo_del_address change_windo">
						<div class="delete">
							<input type="button" value="" onclick="hide_popup(&#39;div_confirm_delete&#39;);">
						</div>
						<div class="content reduce_c_w">
							<p id="p_address_number">
								您真的需要删除地址1 ?
							</p>
							<input id="del_yes" type="button" value="是" onclick="make_del();" class="b_yes">
							<input type="button" value="否" onclick="cancel_del();" class="b_no">
						</div>
					</div>
					<div class="w_add_shadow1">
					</div>
				</div>
				<div class="w_add_shadow2">
				</div>
			</div>
		</div>

	</div>
</div>
<script type="text/javascript">
	//设置默认地址
	function set_default(id)
	{
		$.ajax({
			type: 'GET',
			url:"{{url('/home/address/defaultaddr/')}}/"+id,
			data: {id:id},
			async: false,
			success: function(flg) {
				if (flg == "Y"){
					$("#div_addrs_"+id).css("background-color","#F4FEFF");
					$("#div_addrs_"+id).nextAll().css("background-color","#FFFFFF");
					$("#div_addrs_"+id).prevAll().css("background-color","#FFFFFF");
				}
				else
					alert("设置默认地址薄失败，请重试！");
			},
			error:function(){
				alert("Sorry~~~failed");
			}
		});
	}
</script>
<script type="text/javascript">
	//删除收货地址
	function del(id,ob){
		//获取要删除的地址位置
		var offset = $("#div_addrs_"+id).offset();
		$("#div_confirm_delete").css({top:offset.top+60+"px",left:offset.left+70+"px"}).show();
		delid = id;
		
	}
	//执行删除
	function make_del(){
		
		 $.ajax({
			type:"GET",
			url:"{{url('/home/address/del/')}}/"+delid,
			async:true,       //是否异步
			data:{id:delid}, //请求参数
			dataType:"text",     //响应回来的数据格式
			success:function(res){
				if(res=="Y"){
				  $("#div_addrs_"+delid).remove();
				}else{
					alert("删除失败！");
				}
			},
			error:function(){
				alert("Sorry~~~failed");
			}
			
		}); 
		$("#div_confirm_delete").hide();				
	}
	//取消删除
	function cancel_del(){
		$("#div_confirm_delete").hide();	
	}
</script>
<link href="{{asset('personal/myaddress/footer_150526.css')}}" rel="stylesheet" type="text/css">


<style>
    .foot_tip_ad { width:40px; height:40px; font:12px/40px "simsun"; text-align:center; color:#fff; background-color:#474747; position:fixed; right:0; bottom:100px;_position:absolute; _bottom:auto;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}
</style>

@endsection